package com.sql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SqlManege {
	public Connection doInit(){
		Connection connection=null;
		
		try{ 
			  Class.forName("com.mysql.jdbc.Driver");
			  connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/librarysystem?charaterEncoding=utf-8","root","123456");
			  
			  }
			  catch(Exception e){
				  e.printStackTrace();
			  }
			  
			   return connection;
	}
	
	public void dbclose(Connection connection,Statement statement){
		
		try {
			connection.close();
			statement.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
public void dbclose(Connection connection,Statement statement,ResultSet resultSet){
		
		try {
			connection.close();
			statement.close();
			resultSet.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
